package com.quanyan.user.utils;

import java.util.Random;

/**
 * 百灵鸟号工具
 * Created by zhang on 16/6/28.
 */
public class LarkCodeUtil {



    /**
     * 生成百灵鸟号
     * @param uid
     * @return
     */
    public static String generateLarkCode(int uid){
        Random random = new Random();
        int x = random.nextInt(900)+100;
        StringBuffer larkCode = new StringBuffer();
        larkCode.append(x).append(uid);
        return larkCode.toString();
    }

    /**
     * 生成用户默认昵称
     * @param mobile
     * @return
     */
    public static String generateDefaultNickName(String mobile){
        StringBuffer sb = new StringBuffer();
        if (mobile != null) {
            char[] chars = mobile.toCharArray();
            if (chars.length == 11) {
                sb.append(chars[0]).append(chars[1]).append(chars[2]).append("*")
                        .append(chars[7]).append(chars[8]).append(chars[9]).append(chars[10]);
            }

        }
        return sb.toString();
    }

    public static void main(String[] args) {
//        String  lark = LarkCodeUtil.generateLarkCode(2);
//        System.out.println(lark);

        String mobile = "13522";
        System.out.println(LarkCodeUtil.generateDefaultNickName(mobile));


    }
}
